package com.example.flutter_test_opengl_plugin.board

import android.content.Context
import android.graphics.SurfaceTexture
import android.view.Surface
import android.view.TextureView
import com.example.flutter_test_opengl_plugin.JNIProxy

/** 白板view*/
class WhiteboardTextureView(context: Context) : TextureView(context),
    TextureView.SurfaceTextureListener {

    init {
        // 表面纹理监听器
        surfaceTextureListener = this
    }

    override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) {
        JNIProxy.init(width, height, Surface(surface))
    }

    override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {
    }

    override fun onSurfaceTextureDestroyed(surface: SurfaceTexture): Boolean {
        JNIProxy.destory()
        return false
    }

    override fun onSurfaceTextureUpdated(surface: SurfaceTexture) {
    }

}